using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using emp.ProcessFlow;
using emp.BLL;
using emp.Model;

public partial class crm_quest_qst_relation_create : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            if (Request["qsd_uid"] != null)
            {
                if (Request["cur_page"] != null)
                {
                    currPage.Value = Request["cur_page"].ToString();
                }
                else
                {
                    currPage.Value = "0";
                }
                Quest quest = new Quest();
                p_qsd_id.Value=Request["qsd_uid"].ToString();
                int qsd_id = Convert.ToInt32(Request["qsd_uid"].ToString());
                QuestInfo qstInfo = quest.getQuestInfo(qsd_id);
                this.p_qsd_name.Text = qstInfo.QSD_NAME;
              
                DataSet  ds = quest.getRelateQuestLintOB(qsd_id);             
           
                if (ds != null)
                {
                    select_tem.DataSource = ds;
                    select_tem.DataTextField = "qsd_name";
                    select_tem.DataValueField = "qsd_uid";
                    select_tem.DataBind();                   
                    ds.Dispose();
                  

                }
            }
        }
    }
    protected void button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("RelateQstList.aspx?cur_page="+Convert.ToInt32(currPage.Value));
    }
    protected void submit_Click(object sender, EventArgs e)
    {
        int pid = Convert.ToInt32(p_qsd_id.Value);
        int cid = Convert.ToInt32(select_tem.SelectedValue);
        Quest quest = new Quest();
       int id =  quest.addrelateInfo(pid, cid);
        quest.update(pid, "P");
        Response.Redirect("RelateQstOptionCreate.aspx?pid=" + pid + "&cid=" + cid + "&qsruid=" + id);
    }
}
